
class A123 {
    watch!: object
}

@Com<Post>({
    watch: {
        postId() {
            this.fetchPost()
        }
    }
})
class Post extends A123{
    public name:string = "zhang"
    fetchPost(postId: string): void {
        console.log("Df")
    }
}
// 函数工厂
function Com<V extends A123>(option: {watch: Record<string,any> | any}): any {
    return function (target: Function, key: string, m: object) {
        // 反射创建实例对象
        let construct = Reflect.construct(target, []);

        // 拿到方法（实际是遍历获取，这里模式就简单点）绑定泛型
        let watch = option.watch["postId"];
        let watch1 = watch.bind(construct);
        watch1()
    }
}
